, the browser does not allow direct cross-origin access to resources. The access fails unless configured in the browser on the client. In this case, handler is usually used on the server side, that is, a bridge is established between the script and the resource to allow the script to access the handler in the site, use handler to access external resources. This is a very common practice, and the operation is very simple, because it will be used frequently, so record it here for future use!
Creat
, the browser does not allow direct cross-origin access to resources. The access fails unless configured in the browser on the client. In this case, handler is usually used on the server side, that is, a bridge is established between the script and the resource to allow the script to access the handler in the site, use handler to access external resources. This is a very common practice, and the operation is very simple, because it will be used frequently, so record it here for future use!
Creat
the handler in the site, use handler to access external resources. This is a very common practice, and the operation is very simple, because it will be used frequently, so record it here for future use!
Create a handler in the website, create a generic handler file in Visual Studio, and copy the following code:
Copy code The Code is as follows: Namespace webapplication1
{
Using system;
Using system. IO;
Using system. net;
Using system. text;
Using system. Web;
Using system. Collections. Generi
handler, through the handler to access external resources. This is a very common practice, but also very simple to operate, because it will be used frequently, so here to record, easy to use later!
First you need to create a handler in your Web site, a new generic handler file in Visual Studio, and copy the following code:
Copy Code code as follows:
Namespace WebApplication1
{
Using System;
Using System.IO;
Using System.Net;
Using System.Text;
Using System.Web;
Using System.
safety for iproducerconsumercollectionCollection provides throttling and throttling capabilities.
Concurrentbag
Represents an unordered collection of thread-safe objects.
Concurrentdictionary
Represents a thread-safe collection of key-value pairs that can be accessed concurrently by multiple threads.
Concurrentqueue
Represents a thread-safe FIFO (FIFO) collection.
Concurrentstack
Represents a thread-safe last-in-first-o
. The following is the corresponding code.
1. synchronization is required during iteration. List Synchronizedlist(
NewArraylist Synchronized(Safelist) {iterator While(I. hasnext () system.
Out. Println (I. Next ());}
2. Hide the iterator.
Public
ClassHiddeniterator {
Private
FinalSet NewHashset
Public
Synchronized
VoidAdd (integer I) {set. Add (I );}
Public
Synchronized
VoidRemove (integer I) {set. Remove (I );}
Public
VoidAddtenthings () {random
): Replaces all old values of the List object with the new value List list1 = new ArrayList (); List1.add (123); List1.add (332); List1.add (2332);//list1 copy list list2 to List2 = new ArrayList () ;//Wrong way, because at this time the length of the List2 is 0List list2 = arraylist.aslist (New Object[list1.size ()]); Collections.copy (List2, List1);Synchronization control: Troubleshooting Thread-safety issues when multithreading concurrently accessing collectionsMultiple synchronizedxxx () met
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.